﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using Service.BusinessLayer.Logic;
using Service.BusinessLayer.Entities;
using Service.DataAccess.DataAccessHelper;
namespace Service
{
    /// <summary>
    /// Summary description for WS_TaiKhoan
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class WS_TaiKhoan : System.Web.Services.WebService
    {
        XL_TaiKhoan xltk = new XL_TaiKhoan();

        [WebMethod]
        public string LayDS()
        {
            string kq = "";
            kq = xltk.LayDS().GetXml();
            return kq;
        }
        [WebMethod]
        public string LayDS_TheoTenDangNhap(string TenDangNhap)
        {
            string kq = "";
            kq = xltk.LayDS_Theo_TenDangNhap(TenDangNhap).GetXml();
            return kq;
        }
        [WebMethod]
        public void Them(string MaTK, string MaNV, string TenDangNhap, string MatKhau, string PhanQuyen)
        {
            TaiKhoan tk = new TaiKhoan(MaTK, MaNV, TenDangNhap, MatKhau, PhanQuyen);
            xltk.them(tk);
        }
        [WebMethod]
        public void Sua(string MaTK, string MaNV, string TenDangNhap, string MatKhau, string PhanQuyen)
        {
            TaiKhoan tk = new TaiKhoan(MaTK,MaNV,TenDangNhap,MatKhau,PhanQuyen);
            xltk.sua(tk);
        }
        public void SuaPhanQuyen(string MaTK, string MaNV, string TenDangNhap, string MatKhau, string PhanQuyen)
        {
            TaiKhoan tk = new TaiKhoan(MaTK, MaNV, TenDangNhap, MatKhau, PhanQuyen);
            xltk.SuaPhanQuyen(tk);
        }
        [WebMethod]
        public void SuaMatKhau(string MaTK, string MatKhau)
        {
            TaiKhoan tk = new TaiKhoan();
            tk.Matk = MaTK;
            tk.Matkhau = MatKhau;
            xltk.SuaMatKhau(tk);
        }
        [WebMethod]
        public void Xoa(string TenDangNhap)
        {
            xltk.xoa(TenDangNhap);
        }
        [WebMethod]
        public string SelectSQL(string lenh_sql)
        {
            string kq = "";
            Helper help = new Helper();
            kq = help.SelectQueryByText(lenh_sql).GetXml();
            return kq;
        }
        [WebMethod]
        public void Backup_Data(string filepath)
        {
            TaiKhoan tk = new TaiKhoan();
            tk.Duongdan = filepath;
            xltk.Backup_Data(tk);
        }
        [WebMethod]
        public void Restore_Data(string filepath)
        {
            Helper help = new Helper("kn1");
            help.SelectQueryByText(filepath);
        }
    }
}
